$(document).ready( function(){
	
	scriptsURL = $("#base_url").val();
	
	$("#menu div ul li").hover(function(){
		$(this).addClass("hover");
		$(this).siblings().removeClass("hover");
	});
	
	$("#menu").hover(function(){}, function(){
		$(this).find(".hover").removeClass("hover");
	});
	
	$("#cartContainer").on("click", ".cart", function(){
		$("#smallCart").slideToggle();
		$("#cartContainer").toggleClass("active");
		return false;
	});

	$("#cartContainer").on("click","#smallCart a", function(){
		return this.href;
	});

	$(document).on("click", function(){
		if($("#cartContainer").hasClass("active"))
		{
			$("#smallCart").slideToggle();
			$("#cartContainer").removeClass("active");
		}
	});

	$('.zoom').zoom();

	$(".thumbImages a.thumbImage").on("click", function(){
		var imgSrc = $(this).attr("href");
		$(".mainImage img.mainImage").attr("src", imgSrc);
		$('.zoom').zoom();
		return false;
	});

	$(".selectGroup li a").on("click", function(){
		var selectedVal = $(this).html();
		$(this).parent().parent().siblings(".placeHolder").html(selectedVal);
	});

	$('a.colorbox').colorbox({rel:'gal'});

	$(document).on("click","#printProduct",function(){

		printdiv("productPage");
	});
	

});

function printdiv(printdivname){
	// creeare containere
	var container=$("<div id='printablePage' style='margin-top:20px;display:block;width:800px;float:left'></div>");
	var containerPoza=$("<div style='float:left;width:200px;margin-left:50px;text-align:left;'></div>");
	var containerInf=$("<div style='float:left;width:500px;margin-left:50px; background-color:#FFFFFF;'></div>");

	// preluare informatii
	var productPrice=$(".productPrice").html();
	var productProp=$("#productProperties").html();
	var prodCode=$("#prodCode").text();
	var prodCodeN=$("#prodCodeN").text();
	var pName=$("#pName").text();
	var img=$(".mainImage").html();
	var productDetail=$.trim($("#productPage p").text());

	// introducere informatii in containere
	containerPoza.append(img);
	containerPoza.append("<h5>"+prodCodeN+":  "+prodCode+"</h5>");
	containerInf.append("<h4 style='float:right;'>"+productPrice+"</h4>");
	containerInf.append("<h1>"+pName+"</h1><br/>");
	containerInf.append("<p>"+productDetail+"</p>");
	container.append(containerPoza);
	container.append(containerInf); 

	// deschidere print window
	var thePopup=window.open( '', "Product Print", "height=900,width=900;titlebar=1;" );
	container.clone().appendTo( thePopup.document.body );
	thePopup.print();
	thePopup.close();


	return false;
}

	

